package com.hj.authority.feign;

import com.hj.authority.domain.query.ThreeReq;
import com.hj.authority.feign.fallback.RemoteStorageServiceFactory;
import com.hj.authority.feign.fallback.RemoteStorageServiceImpl;
import com.hj.response.constant.AppNameConstant;
import com.hj.response.resp.RestfulResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author hj
 * @Date 2023/5/20
 * @Description:
 */
@FeignClient(contextId = "remoteStorageService", value = AppNameConstant.STORAGE,path = "/file",
        fallbackFactory = RemoteStorageServiceFactory.class,fallback = RemoteStorageServiceImpl.class)
public interface RemoteStorageService {

    /**
     * 调用storage服务的random/one接口
     * 必须加 @RequestParam 否则对方接收不到这个参数
     *
     * @param name name
     * @return String
     */
    @PostMapping("/random/one")
    String randomOne(@RequestParam("name") String name);


    /**
     * 调用storage服务的random/two接口
     * 之所以能用 RestfulResult接收,是因为对方是直接返回这个,而没有经过全局返回处理器做处理
     * <p>
     * 必须加 @RequestParam 否则请求会被转化为post
     *
     * @param name name
     * @return String
     */
    @GetMapping("/random/two")
    RestfulResult<String> randomTwo(@RequestParam("name") String name);

    /**
     * 调用storage服务的random/three接口
     *
     * @param req name
     * @return String
     */
    @PostMapping("/random/three")
    String randomThree(ThreeReq req);

    /**
     * 调用storage服务的random/four接口
     *
     * @param req name
     * @return String
     */
    @PostMapping("/random/four")
    String randomFour(@RequestBody ThreeReq req);


}
